import { useState, useEffect } from "react";
import { Col, Form, Row, Space } from "antd";
import { CommonModal } from "@/views/components/CommonModal";
import { SimpleTable } from "@/views/components/SearchTable/index";
import { useTableConfig } from "@/views/components/SearchTable/hooks/useTableConfig";
import { getInventoryLogList } from "../service";

const UpdateLogListModal = ({ visible, handleCancel, record }) => {
	const [form] = Form.useForm();
	useEffect(() => {}, [visible]);

	const onOk = () => {
		onCancel();
	};
	const onCancel = () => {
		handleCancel();
		form.resetFields();
	};
	const tableRequest = getInventoryLogList;
	const columns = [
		{
			name: "操作人账号",
			code: "operator"
		},
		{
			name: "操作人类型",
			code: "subType",
			render: (value, record, i) => (
				<div>
					{value == "actual-num-count"
						? "正品盘点"
						: value == "defective-num-count"
							? "次品盘点"
							: value == "release-inventory"
								? "释放库存"
								: "增加库存"}
				</div>
			),
			width: 100
		},
		{
			name: "操作事件",
			code: "action"
		},
		{
			name: "操作时间",
			code: "createTime",
			width: 160
		}
	];
	const rowKey = "skuId";
	const tableKey = "SeparateStock2123";
	const {
		selectedKeys,
		selectedRows,
		fetchList,
		dataSource,
		query,
		pagination,
		updateDataSource,
		updateSearchQuery,
		updatePaginationParams,
		searchSimpleTableProps
	} = useTableConfig({
		tableKey,
		rowKey,
		columns,
		tableRequest,
		autoFetch: true,
		hasPagination: true,
		hasQuickSearch: true,
		beforeQuerySearch: ({ API_DATA }) => {
			return {
				...API_DATA,
				bizNo: record.skuId,
				extra: record.warehouseId
			};
		},
		resetSourceData: false,
		columnResize: true,
		hasColsSetting: true
	});
	return (
		<CommonModal
			title={{ title: "修改日志" }}
			className="views-table-dialog"
			visible={true}
			onOk={onOk}
			width={"588px"}
			onCancel={onCancel}
			minHeight="150px"
		>
			<Form name="mark-unuaual-modal">
				<div className="views-container">
					<SimpleTable key={tableKey} {...searchSimpleTableProps} />
				</div>
			</Form>
		</CommonModal>
	);
};

export default UpdateLogListModal;
